import request from "@/utils/request";
import type {Result} from "@/types/common/Result";
import type {LikeDTO} from "@/types/vo/LikeDTO";
import type {LikeQuery} from "@/types/query/LikeQuery";
import type {PageResult} from "@/types/common/PageResult";
import type {ArticleVO} from "@/types/vo/ArticleVO";

/**
 * 点赞数
 * @param articleId
 */
export function getLikedCountService(articleId:number) {
  return request.get<Result<number>>(`/article/liked/likedCount?articleId=${articleId}`);
}

/**
 * 查询是否点赞
 * @param {string} articleId articleId
 * @returns
 */
export function getIsLiked(articleId:number) {
  return request.post<Result<boolean>>(`/article/liked/isLiked?articleId=${articleId}`);
}

/**
 * 点赞或取消
 * @param {object} params 文章点赞表
 * @param {number} params.articleId 题目id
 * @param {number} params.id 主键
 * @param {string} params.likeUserId 点赞人id
 * @param {number} params.status 点赞状态 1点赞 0不点赞
 * @returns
 */
export function likeClickService(params:LikeDTO) {
  return request.post<Result<any>>(`/article/liked/click`, params);
}

/**
 * 我的点赞
 * @param {object} params 点赞查询对象
 * @param {boolean} params.isAsc 是否升序
 * @param {number} params.pageNum 页码
 * @param {number} params.pageSize 每页记录数
 * @param {string} params.sortBy 排序字段
 * @returns
 */
export function getMyLiked(params: LikeQuery) {
  return request.post<Result<PageResult<ArticleVO>>>(`/article/liked/myLiked`, params);
}
